package ncsutest.util;

public class Semaphore {
	private int counter;
	public Semaphore(int counter) {
		this.counter = counter;
	}
	
	public synchronized void acquire() {
		try {
			while (counter <= 0) wait();
		} catch (InterruptedException ie) {}
		
		counter--;
	}
	
	public synchronized void release() {
		counter++;
		
		if (counter == 1) notify();
	}
}
